﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;
using Microsoft.Reporting.WinForms;
using CrystalDecisions.Shared;
using System.IO;
namespace QUANLYDIEMHOCSINH
{
    public partial class frmDiemHS : Form
    {
        DIEMBUS diembus = new DIEMBUS();
        LOPBUS lopbus = new LOPBUS();
        HOCSINHBUS hsbus = new HOCSINHBUS();
        public frmDiemHS()
        {
            InitializeComponent(); 
           
        }
       
        private int mahocsinh;

        public int Mahocsinh
        {
            get { return mahocsinh; }
            set { mahocsinh = value; }
        }
        private string tenhs;

        public string Tenhs
        {
            get { return tenhs; }
            set { tenhs = value; }
        }
        private int namhoc;

        public int Namhoc
        {
            get { return namhoc; }
            set { namhoc = value; }
        }
        private int hocky;

        public int Hocky
        {
            get { return hocky; }
            set { hocky = value; }
        }
        public string DiemTB { get; set; }
        private void frmDiemHS_Load(object sender, EventArgs e)
        {
            DataTable dts = new DataTable();
            dts = diembus.LoadDiemHocSinh(hocky, mahocsinh, namhoc);

            crpDiemHS objRpt = new crpDiemHS();
            objRpt.SetDataSource(dts);
            rpDiem.ReportSource = objRpt;
            rpDiem.Refresh();

            
            //truyền tham số cho report
            HOCSINHDTO hs = new HOCSINHDTO();
            hs = hsbus.lay_hocsinh(Mahocsinh);

            ParameterFields crtParamFields = new ParameterFields();
            ParameterDiscreteValue t = new ParameterDiscreteValue();
            t.Value = hs.TENHS;
            ParameterField ten = new ParameterField();
            ten.ParameterFieldName = "txtTenHS";
            ten.CurrentValues.Add(t);
            crtParamFields.Add(ten);

            ParameterDiscreteValue l = new ParameterDiscreteValue();
            l.Value = lopbus.LayTenLop(Mahocsinh);
            ParameterField lop = new ParameterField();
            lop.ParameterFieldName = "txtLop";
            lop.CurrentValues.Add(l);
            crtParamFields.Add(lop);

            ParameterDiscreteValue n = new ParameterDiscreteValue();
            n.Value = hs.NGAYSINH;
            ParameterField ns = new ParameterField();
            ns.ParameterFieldName = "txtNgaySinh";
            ns.CurrentValues.Add(n);
            crtParamFields.Add(ns);

            ParameterDiscreteValue d = new ParameterDiscreteValue();
            d.Value = DiemTB;
            ParameterField diemtb = new ParameterField();
            diemtb.ParameterFieldName = "txtDiemTB";
            diemtb.CurrentValues.Add(d);
            crtParamFields.Add(diemtb);

            rpDiem.ParameterFieldInfo = crtParamFields;
        }
    }
}
